<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <ul>
      <li>data1</li>
      <li id="l2">data2</li>
      <li>data3</li>
      <li>data4</li>
    </ul>

    <input type="checkbox" name="likes" value="LOL" />LOL
    <input type="checkbox" name="likes" value="DOTA" />DOTA
    <input type="checkbox" name="likes" value="CS" />CS
  </body>
</html>
<script>
  //1. 根据id 获得 单个元素节点
  var liComp = document.getElementById('l2')
  console.log('===liComp========' + liComp)

  //2. 根据name属性取值 数组
  var likesCompAy = document.getElementsByName('likes')
  console.log('=====likesCompAy[1]==========' + likesCompAy[1].value)

  //3. 根据 标签input li 取值 数组
  var liCompAy = document.getElementsByTagName('li')
  console.log('======liCompAy[2]========' + liCompAy[2].innerText)

  //4. 选择器 获得 单个元素
  var liComp2 = document.querySelector('#l2')
  console.log('----liComp2-------' + liComp2.textContent)

  //5. 根据选择器 获得 元素数组
  var inputCompAy = document.querySelectorAll('input')
  console.log('===============inputCompAy======' + inputCompAy[2].value)
</script>
